package com.hlmc.spider;

import com.hlmc.dao.YunBoDao;
import com.hlmc.entity.DS360_dt;
import com.hlmc.entity.Yun_Video;
import com.hlmc.util.Atool;
import org.springframework.stereotype.Service;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

import javax.annotation.Resource;
import java.util.Map;

@Service("yun_pipeline")
public class yun_pipeline implements Pipeline {

    @Resource
    private YunBoDao yunDao;
    @Override
    public void process(ResultItems resultItems, Task task) {

        Map<String, Object> mapResults = resultItems.getAll();
        Yun_Video dt = null;
        try {
            dt = (Yun_Video) Atool.mapToObject(mapResults, Yun_Video.class);
            if (dt.getImage() != null) {
                yunDao.AddYun_video(dt);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
